/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package System.model;

import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author GuloTosh
 */
public class Place {
    int id;
    String nome;
    int id_admin;
    ArrayList Service = new ArrayList<Service>();
    public Place(int id, String nome) {
        this.id = id;
        this.nome = nome;
    }

    public Place() {
 
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getId_admin() {
        return id_admin;
    }

    public void setId_admin(int id_admin) {
        this.id_admin = id_admin;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public ArrayList getService() {
        return Service;
    }

    public void addService( Service serv) {
        this.Service.add(serv);
    }


    public JSONObject toJson() throws JSONException{

        JSONObject json = new JSONObject();
        json.put("id", this.getId());
        json.put("nome", this.getNome());

        JSONArray services = new JSONArray();
        for (int i = 0; i < Service.size(); i++) {
            services.put(((Service)Service.get(i)).toJson());
        }
        json.put("services", services);

        return json;

    }


}
